Half = {}

local HALF_TIME = 5

function Half.Start()	
	Half.TimeLeft = HALF_TIME
	Round.Start()	
	timer.Create("Half time up", 1, 0, Half.DecreaseTimer)
end

function Half.End()
	PrintMessage(HUD_PRINTTALK, "Half end")
	timer.Remove("Half time up")
	Round.End()
	gamemode.Call("TimeUp")	
end

function Half.DecreaseTimer()
	Half.TimeLeft = Half.TimeLeft - 1
	PrintMessage(HUD_PRINTCENTER, GetStringTime(Half.TimeLeft))
	if Half.TimeLeft <= 0 then		
		Half.End()
	end
end

function GetStringTime(time)
	local seconds = time % 60
	local minutes = math.floor(time / 60)
	local zero = ""
	if (seconds < 10) then
		zero = "0"
	end
	return tostring(minutes)..":"..zero..tostring(seconds)
end

hook.Add("RoundStart", "Half.OnRoundStart", function()
	timer.UnPause("Half time up")
end)

hook.Add("Goal", "Half.OnGoal", function()
	timer.Pause("Half time up")
end)